Skip to content

feat: maxLength - #755

Open
hejsztynx wants to merge 14 commits into
mainfrom
@ksienkiewicz/feat-max-length
Open

feat: maxLength#755
hejsztynx wants to merge 14 commits into
mainfrom
@ksienkiewicz/feat-max-length

Conversation

@hejsztynx

Copy link
Copy Markdown
Collaborator

Summary

Closes #732.

Provided the implementation of the maxLength prop to the EnrichedTextInput component.

  • The prop is optional and if assigned with a value, the EnrichedTextInput's content will be limited to the given number of characters
  • The prop is respected on every input's entry-point, such as setValue, defaultValue, typing, pasting content or programmatically via ref.setImage(), ref.setImage(), ref.setLink()
  • Provided relevant e2e tests on all platforms

Test Plan

There's an available interface on mobile on the TestScreen and under /test-max-length URL on web.

Compatibility

OS Implemented
iOS
Android
Web

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

@hejsztynx
hejsztynx requested a lite review from Copilot August 10, 2026 10:14
@hejsztynx
hejsztynx marked this pull request as draft August 10, 2026 10:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds maxLength?: number support to EnrichedTextInput across Web/iOS/Android, enforcing the limit based on the editor’s plain text (ignoring ZWS) across typing, paste, and programmatic entry points, with new e2e coverage and demo screens.

Changes:

  • Web: introduce a ProseMirror/Tiptap max-length extension and wire the new prop into the web editor setup.
  • Native: expose maxLength through the RN spec/manager and enforce it in iOS (utilities + insertion points) and Android (InputFilter + insertion helpers).
  • Tooling/docs/tests: document the prop, add example/test screens, and add Playwright + Maestro e2e coverage.

Reviewed changes

Copilot reviewed 24 out of 38 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/web/pmPlugins/MaxLengthPlugin.ts New Tiptap/ProseMirror plugin that trims inserted ranges when doc exceeds maxLength.
src/web/EnrichedTextInput.tsx Wires maxLength into the web editor via the new plugin.
src/types.ts Adds maxLength?: number to EnrichedTextInputProps.
src/spec/EnrichedTextInputNativeComponent.ts Exposes maxLength to native via codegen (default -1).
src/native/EnrichedTextInput.tsx Passes maxLength prop through to the native component.
ios/utils/MaxLengthUtils.mm Adds iOS utilities for plain-length counting and safe truncation (composed characters).
ios/utils/MaxLengthUtils.h Declares the new iOS max-length helper API.
ios/styles/MentionStyle.mm Makes mention insertion respect remaining capacity and clamps mention range when truncated.
ios/inputHtmlParser/InputHtmlParser.mm Truncates parsed HTML processing results (text/styles/alignments) to capacity and truncates fallback raw insertion.
ios/EnrichedTextInputView.mm Applies maxLength config updates; truncates defaultValue/setValue; enforces maxLength in typing path; clamps link/image insertions.
ios/enrichedInputTextView/EnrichedInputTextView.mm Truncates pasted plain text fragments to remaining capacity.
ios/config/EnrichedConfig.mm Stores and normalizes maxLength in config (<0 => unlimited).
ios/config/EnrichedConfig.h Defines EnrichedMaxLengthUnlimited and adds config getter/setter.
docs/INPUT_API_REFERENCE.md Documents the new maxLength prop behavior and platforms.
apps/example/src/screens/TestScreen.tsx Adds UI controls to toggle maxLength in the native example app.
apps/example-web/src/testScreens/TestMaxLength.tsx Adds a dedicated web test screen exercising maxLength across entry points.
apps/example-web/src/RouteSelector.tsx Adds routing to the new /test-max-length web test screen.
android/src/main/java/com/swmansion/enriched/textinput/utils/MaxLengthFilter.kt Adds maxLength grapheme-safe truncation helpers and an InputFilter enforcing the limit.
android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpannable.kt Adds helper to replace/insert while reporting actual inserted length (post-filter).
android/src/main/java/com/swmansion/enriched/textinput/styles/ParametrizedStyles.kt Updates link/image/mention insertion to respect maxLength shortening/rejection.
android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputViewManager.kt Adds @ReactProp(maxLength) plumbing to the Android manager.
android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt Installs maxLength filter and truncates pasted fragments to preserve post-caret content.
.playwright/tests/maxLength.spec.ts Adds Playwright e2e tests covering typing/paste/selection replace/link/mention/image behaviors.
.maestro/scripts/setup-android-emulator.sh Adjusts emulator port used by Maestro setup script.
.maestro/enrichedInput/flows/max_length.yaml Adds Maestro flow validating native maxLength behavior (typing/paste/set value/link/mention).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/example/src/screens/TestScreen.tsx
Comment thread docs/INPUT_API_REFERENCE.md Outdated
Comment thread src/web/pmPlugins/MaxLengthPlugin.ts
@hejsztynx
hejsztynx marked this pull request as ready for review August 10, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] maxLength for EnrichedTextInput, including paste and dictation

2 participants